

//
//  ZYFundManagermentCell.m
//  优学荟管理系统
//
//  Created by Ethan on 2017/9/19.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYFundManagermentCell.h"
#import "ZYFundManagerModel.h"
@implementation ZYFundManagermentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        [self setUpSuperView];
    }
    
    
    return self;
    
}

- (void)assignByZYFundManagerModel:(ZYFundManagerModel *)model{
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@",model.tradeTime];
    
    
    BOOL isUp = [self isBlankString:model.payName];
    
    if (isUp) {
          self.nameLabel.text =@"无";
    }else{
          self.nameLabel.text =[NSString stringWithFormat:@"%@",model.payName];
    }
    
    BOOL isTow = [self isBlankString:model.courseName];
    
    
    if (isTow) {
          self.couseTypeLabel.text =@"无";
    }else{
          self.couseTypeLabel.text = [NSString stringWithFormat:@"%@",model.courseName];
    }
    
  
  
    

    
    if (-1 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]) {
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(未提现)",[model.actualPaid doubleValue]];
        self.accountNumberLabel.textColor = ColorRGB(246, 50, 96);
    }else if (0 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]){
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(提现中)",[model.actualPaid doubleValue]];
        self.accountNumberLabel.textColor = ColorRGB(57, 136, 185);
    }else if (1 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]){
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(财务拒绝)",[model.actualPaid doubleValue]];
    }else if (2 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]){
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(财务同意)",[model.actualPaid doubleValue]];
    }else if (3 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]){
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(终审拒绝)",[model.actualPaid doubleValue]];
    }else if (4 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]){
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(终审同意)",[model.actualPaid doubleValue]];
    }else if (5 == [[model.withdraw valueForKey:@"withdrawFlag"] integerValue]){
        self.accountNumberLabel.text = [NSString stringWithFormat:@"+%.2f(已提现)",[model.actualPaid doubleValue]];
    }
    
    
    
}

 


- (void)setUpSuperView{
    
    
    self.timeLabel = [UILabel new];
    self.timeLabel.text = @"2017-08-30-42";
    self.timeLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.timeLabel];
    
    
    
    self.accountNumberLabel = [UILabel new];
    self.accountNumberLabel.font = [UIFont systemFontOfSize:16];
    self.accountNumberLabel.textColor = ColorRGB(102, 102, 102);
    self.accountNumberLabel.text = @"1234567890";
    self.accountNumberLabel.textAlignment = NSTextAlignmentCenter;
    
    
    self.nameLabel = [UILabel new];
    self.nameLabel.font = [UIFont systemFontOfSize:12];
    self.nameLabel.textColor = ColorRGB(102, 102, 102);
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.text = @"1234567890";
    
    
    self.couseTypeLabel = [UILabel new];
    self.couseTypeLabel.font = [UIFont systemFontOfSize:12];
    self.couseTypeLabel.textColor = ColorRGB(102, 102, 102);
    self.couseTypeLabel.text = @"数学课";
    
    
    
    self.studentButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.studentButton setTitle:@"详情" forState:(UIControlStateNormal)];
    [self.studentButton setTitleColor:ColorRGB(42, 197, 127) forState:(UIControlStateNormal)];
    self.studentButton.titleLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.studentButton];
    
    
    
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.offset(8);
        
    }];
    
    UIView *view = [UIView new];
    view.backgroundColor = ColorRGB(247, 244, 248);
    [self.contentView addSubview:view];
    
    [view addSubview:self.nameLabel];
    [view addSubview:self.couseTypeLabel];
    [view addSubview:self.accountNumberLabel];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.timeLabel.mas_bottom).offset(8);
        make.width.offset(SCREEN_WIDTH);
        make.height.offset(60);
    }];
    
    
    
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.left.equalTo(self.timeLabel);
        make.top.equalTo(view).offset(0);
        make.height.offset(30);
        
    }];
    
    
    [self.couseTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(0);
        make.height.equalTo(self.nameLabel);
        
    }];
    
    
    [self.accountNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(view);
        make.right.equalTo(view).offset(-8);
    }];
    
    
    [self.studentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.centerY.equalTo(self.timeLabel);
        make.width.offset(80);
        make.right.equalTo(self).offset(-8);
    }];
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(view).offset(5);
    }];
}

- (BOOL) isBlankString:(NSString *)string {
    if (string == nil || string == NULL) {
        return YES;
    }
    if ([string isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    return NO;
}

@end
